package org.jeecg.modules.tankerRegistration.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.tankerRegistration.entity.TankerRegistration;
import org.jeecg.modules.tankerRegistration.mapper.TankerRegistrationMapper;
import org.jeecg.modules.tankerRegistration.service.ITankerRegistrationService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 罐车登记表
 * @Author: jeecg-boot
 * @Date:   2024-10-28
 * @Version: V1.0
 */
@Service
public class TankerRegistrationServiceImpl extends ServiceImpl<TankerRegistrationMapper, TankerRegistration> implements ITankerRegistrationService {

    @Override
    public TankerRegistration getByOpenId(String openId) {
        LambdaQueryWrapper<TankerRegistration> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TankerRegistration::getOpenId, openId);
        wrapper.orderByDesc(TankerRegistration::getCreateTime);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public List<TankerRegistration> getBackups(String createTime) {
        return baseMapper.getBackups(createTime);
    }

    @Override
    public TankerRegistration getByPlateNo(String plateNo) {
        LambdaQueryWrapper<TankerRegistration> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TankerRegistration::getPlateNo, plateNo);
        wrapper.orderByDesc(TankerRegistration::getCreateTime);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

}
